package com.example.springboot_demo.controller;

import com.example.springboot_demo.bean.User;
import com.example.springboot_demo.mapper.TestMapper;
import com.example.springboot_demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    TestService testService;

    @Autowired
    TestMapper testMapper;

    @RequestMapping()
    public String test(){
        return "hello world";
    }

    @PostMapping("/query")
    public Object testSql() throws SQLException {
        Object o = testService.queryOne();
        return o;
    }


    @PostMapping("/add_user")
    public boolean addUser(@RequestBody User user){
        boolean b = testService.addUser(user);
        return b;
    }

    @GetMapping("/query_user_list")
    public List<User> queryUserList(){
        List<User> userList = testMapper.getUserList();

        return userList;
    }
}
